package top.xiaoqiannb.shapelessdao.procedures;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.Entity;
import net.minecraft.util.RandomSource;
import net.minecraft.network.chat.Component;

public class FCopperStringProcedure {
	public static void execute(LevelAccessor world, Entity entity, ItemStack itemstack) {
		if (entity == null)
			return;
		double randomGua = 0;
		randomGua = (int) (Math.random() * 8) + 1;;
		{
			ItemStack _ist = itemstack;
			if (_ist.hurt(1, RandomSource.create(), null)) {
				_ist.shrink(1);
				_ist.setDamageValue(0);
			}
		}
		if (entity instanceof Player _player)
			_player.getCooldowns().addCooldown(itemstack.getItem(), 1200);
		if (entity instanceof Player _player && !_player.level().isClientSide())
			_player.displayClientMessage(Component.literal("\u00A76\u94DC\u5E01\u7ED9\u51FA\u7684\u5366\u8C61\u662F"), false);
		if (randomGua == 1) {
			if (entity instanceof Player _player && !_player.level().isClientSide())
				_player.displayClientMessage(Component.literal("\u574E\u5366"), false);
			Kan1Procedure.execute(entity);
		} else if (randomGua == 2) {
			if (entity instanceof Player _player && !_player.level().isClientSide())
				_player.displayClientMessage(Component.literal("\u5764\u5366"), false);
			Kun2Procedure.execute(world, entity);
		} else if (randomGua == 3) {
			if (entity instanceof Player _player && !_player.level().isClientSide())
				_player.displayClientMessage(Component.literal("\u9707\u5366"), false);
			Zhen3Procedure.execute(world, entity);
		} else if (randomGua == 4) {
			if (entity instanceof Player _player && !_player.level().isClientSide())
				_player.displayClientMessage(Component.literal("\u5DFD\u5366"), false);
			Xun4Procedure.execute(entity);
		} else if (randomGua == 5) {
			if (entity instanceof Player _player && !_player.level().isClientSide())
				_player.displayClientMessage(Component.literal("\u4E7E\u5366"), false);
			Qian6Procedure.execute(entity);
		} else if (randomGua == 6) {
			if (entity instanceof Player _player && !_player.level().isClientSide())
				_player.displayClientMessage(Component.literal("\u5151\u5366"), false);
			Dui7Procedure.execute(entity);
		} else if (randomGua == 7) {
			if (entity instanceof Player _player && !_player.level().isClientSide())
				_player.displayClientMessage(Component.literal("\u826E\u5366"), false);
			Gen8Procedure.execute(entity);
		} else if (randomGua == 8) {
			if (entity instanceof Player _player && !_player.level().isClientSide())
				_player.displayClientMessage(Component.literal("\u79BB\u5366"), false);
			Li9Procedure.execute(entity);
		}
	}
}
